<template>
	<view class="tabPan shadow flex">
		<view :class="[item.midButton?'midButton':'tabItem']" v-for="(item,index) of tabBar" :key="index"
			@click="tabChange(index)">
			<image :src="currentRoute===item.pagePath?item.selectedIconPath:item.iconPath" class="tabIcon" />
			<view :class="[mt10,{primary:currentRoute===item.pagePath}]">{{item.text}}</view>
		</view>
	</view>
</template>

<script>
	import {
		getCurrentPath
	} from "@/utils/tools";
	export default {
		name: "tabBar",
		props: {
			tabBar: {
				type: Array,
				default: []
			},
		},
		data() {
			return {

			}
		},
		computed: {
			currentRoute() {
				return getCurrentPath()
			}
		},
		mounted() {

		},
		methods: {
			tabChange(index) {
				this.$emit('tabChange', index);
			}
		}
	}
</script>

<style scoped lang='scss'>
	.tabPan {
		position: fixed;
		width: 100%;
		bottom: 0;
		height: 150upx;
		background-color: #fff;
		border-radius: 40upx 40upx 0 0;

		.tabItem {
			color: #c4c7cc;
			flex: 1;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;

			.tabIcon {
				width: 40upx;
				height: 44upx;
			}

			&.on {
				color: #0a7b65;
			}
		}

		.midButton {
			.tabIcon {
				width: 128upx;
				height: 128upx;
				margin-top: -64upx;
			}
		}
	}

	.scanner {
		position: relative;
		margin-top: -64upx;

		.icon {
			width: 128upx;
			height: 128upx;
		}
	}
</style>
